
<div class="col-md-9">
  <form method="POST" action="/users/edit/{{employee.id}}/">

  <input type="hidden" name="back_to_absences" value="1">
  <input type="hidden" name="name" value="{{employee.name}}">
  <input type="hidden" name="lastname" value="{{employee.lastname}}">
  <input type="hidden" name="email_address" value="{{employee.email}}">
  <input type="hidden" name="department" value="{{employee.DepartmentId}}">
  <input type="hidden" name="admin" value="{{#if employee.admin}}1{{else}}0{{/if}}">
  <input type="hidden" name="start_date" value="{{as_date employee.start_date}}">
  <input type="hidden" name="end_date" value="{{as_date employee.end_date}}">

  {{> user_details/breadcrumb employee=employee }}

  <div class="form-group">
    <label class="control-label">Overview</label>
    <div class="progress bigger">
      <div
        class="progress-bar progress-bar-success"
        style="width: {{ leave_statistics.used_so_far_percent }}%"
        data-content="{{# with employee }}{{this.full_name }}{{/with}} in current year used {{ leave_statistics.used_so_far }} days from allowance"
        data-placement="top"
        data-toggle="popover"
        data-trigger="focus hover"
      >
        {{ leave_statistics.used_so_far }} days used so far
      </div>
      <div
        class="progress-bar progress-bar-warning"
        style="width: {{ leave_statistics.remaining_percent }}%"
        data-content="{{# with employee }}{{this.full_name }}{{/with}} in current year has {{ leave_statistics.remaining }} remaining days in allowance"
        data-placement="top"
        data-toggle="popover"
        data-trigger="focus hover"
      >
        {{ leave_statistics.remaining  }} days remaining in current year
      </div>
    </div>
  </div>

  <div class="form-group">
    <label class="control-label">Days available for {{ employee.name }} to take this year</label>
    <p>{{ user_allowance.number_of_days_available_in_allowance }} out of {{ user_allowance.total_number_of_days_in_allowance }} in allowance</p>
    <input id="days_remaining_inp" type="hidden" value="{{ user_allowance.number_of_days_available_in_allowance }} out of {{ user_allowance.total_number_of_days_in_allowance }}">
  </div>

  <div class="form-group">
    <label class="control-label">Is Accrued Allowance?</label>
    <p>{{# if user_allowance.is_accrued_allowance }}Yes{{else}}No{{/if}}</p>
    <span class="help-block">
      The way of available allowance calculation is defined on department level. <a href="/settings/departments/edit/{{employee.DepartmentId}}">More details <i class="fa fa-angle-double-right"></i></a>
    </span>
  </div>

  <div class="row">
    <div class="col-md-5">
      <dl>
        <dt>Absences used this year grouped by leave types</dt>
        {{# if leave_type_statistics }}
          {{# each leave_type_statistics }}
            <dd><em>{{this.leave_type.name}}:</em> <span class="pull-right">{{this.days_taken}}{{# if this.limit}} out of {{this.limit}}{{/if}}</span></dd>
          {{/each}}
        {{else}}
          <dd class="text-muted">No approved requests so far.</dd>
        {{/if}}
      </dl>
    </div>

    <div class="col-md-5 col-md-offset-2">
      {{> user_details/allowance_breakdown user_allowance = user_allowance }}
    </div>
  </div>

  <div class="form-group">
    <label for="carried_over_allowance_inp" class="control-label">Allowance carried over from previous year</label>
    <div class="input-group col-md-4">
      <input class="form-control" readonly id="carried_over_allowance_inp" type="number" step="0.5" name="carried_over_allowance" value="{{#if carried_over_allowance }}{{carried_over_allowance}}{{else}}0{{/if}}" aria-describedby="carried_over_allowance_help">
      <span class="input-group-addon">working days</span>
    </div>
    <div id="carried_over_allowance_help" class="help-block">
      <div>Allowance adjustment based on unused holidays from previous year.</div>
      <div>It is calculated at the beginning of current year.</div>
    </div>
  </div>

  <div class="form-group">
    <label for="adjustment_inp" class="control-label">Allowance adjustment in current year</label>
    <div class="input-group col-md-4">
      <input class="form-control" id="adjustment_inp" type="number" step="0.5" name="adjustment" value="{{#if employee_adjustment }}{{employee_adjustment}}{{else}}0{{/if}}" aria-describedby="adjustment_help">
      <span class="input-group-addon">working days</span>
    </div>
    <div id="adjustment_help" class="help-block">
      <div>Tune allowance for this user in current year.</div>
      <div>Could be negative as well.</div>
      <div>The value is valid during current year. Next year it needs to be re-confirmed.</div>
    </div>
  </div>

  <div class="form-group">
    <div class="col-md-12">
      <button id="save_changes_btn" type="submit" class="btn btn-success pull-right single-click">Save changes</button>
    </div>
  </div>
  </form>

  <div class="main-row_header">&nbsp;</div>

  {{> user_requests_grouped grouped_leaves=grouped_leaves logged_user=logged_user }}

</div>
